package com.lk.mi.mapper;

import com.lk.mi.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface userMapper {

    /**
     * 登录
     * 根据用户名和用户密码查找用户
     * @param username
     * @param password
     * @return
     */
    @Select("select * from user where username=#{username} and password=#{password}")
    User login(@Param("username") String username, @Param("password") String password);

    /**
     * 注册
     * @param username
     * @param password
     * @return
     */
    @Insert("insert into user values (0,#{username},#{password},0)")
    Integer register(@Param("username") String username, @Param("password") String password);

    /**
     * 注销账号
     * @param id
     * @return
     */
    @Delete("delete from user where id = #{id}")
    Integer destroy(Integer id);


}
